package com.dementors;

import android.app.Application;
import android.content.Context;
import com.dementors.commonlibrary.xuye.utils.TestUrls;
import com.dementors.net.http.okhttp.OkHttpClientManager;
import com.dementors.net.http.volley.VolleyQueue;
import com.dementors.qrcode.ImageLoaderHelper;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.squareup.okhttp.OkHttpClient;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import okio.Buffer;

/**
 * Author  : itxuye(itxuye@gmail.com)|(http://itxuye.com)
 * Date    : 2015-11-30
 * Time    : 22:14
 * FIXME
 */
public class APP extends Application implements TestUrls {

  private Context mContext;

  @Override public void onCreate() {
    super.onCreate();
    mContext = this;
    initHttpClient();
    VolleyQueue.init(mContext); ImageLoader.getInstance().init(
        ImageLoaderHelper.getInstance(this)
            .getImageLoaderConfiguration("/beibei/Images/"));
  }

  /*
   初始化Okhttp
 */
  private void initHttpClient() {
    OkHttpClientManager.getInstance().setCertificates(new InputStream[] {
        new Buffer().writeUtf8(CER_12306).inputStream()
    });
    OkHttpClient httpClient = OkHttpClientManager.getInstance().getOkHttpClient();
    httpClient.setConnectTimeout(10 * 1000, TimeUnit.MILLISECONDS);
    httpClient.setWriteTimeout(30 * 1000, TimeUnit.MILLISECONDS);
    httpClient.setWriteTimeout(30 * 1000, TimeUnit.MILLISECONDS);
  }

  //private void getWidthandHeight() {
  //
  //  DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
  //  displayMetrics.widthPixels;
  //}
  //
}
